#pragma once
//#define byte unsigned char
#define BUFFSIZE 1024
#include <stdlib.h>
#include <string.h>
namespace NOEXIT
{


	enum NETMESSAGE
	{
		LOGIN = 0,
		LOGIN_SUCCEED,
		LOGOUT,
		HEARTBEAT,
		LISTCLIENTS,
		LISTCLIENTS_SUCCEED,
		RTT,
		RTT_SUCCEED,
		SHOOT,
		HEALTHCHANGE,
		DIE,
		GAMEOVER,
		ACK,//ack for those guarantee

		UPDATEPLAYERS,
		PLAYERMOVE,
		RESETPLAYER,
		PLAYERLEAVE,
		PLAYERSHOOT,
		ADDBULLET,
		REMOVEBULLET,
		USELESS,
		TOTAL
	};

	struct PlayerInfo
	{
		int playerId;
		float pos[3];
		float rotation[3];
		float velocity[3];
		int state;

		PlayerInfo(int id):
			state(0),playerId(id)
		{
			pos[0] = getRand(100,850);
			pos[1] = 0;
			pos[2] = getRand(100,850);

			rotation[0] = rotation[1] = rotation[2] = 0;
			velocity[0] = velocity[1] = velocity[2] = 0;
		}

		float getRand(float start, float end)
		{
		return start + (end-start) * ((float)rand())/RAND_MAX;
		}
	};


	struct BulletInfo
	{
		int playerId;
		float pos[3];
		float velocity[3];
		long long spawnTime;//server side
		int bulletId;

		BulletInfo(PlayerInfo& pinfo, float* vel)
			:playerId(pinfo.playerId),spawnTime(0),bulletId(-1)
		{
			memcpy(pos, pinfo.pos, 3*sizeof(float));
			memcpy(velocity, vel, 3*sizeof(float));
		}
	};
	
	struct SMsg
	{
		
		long long msgOrder;//for guaraentee 8
		long long time; // 8
		unsigned int dataSize;// 4
		int msgId;//NETMESSAGE 4
		int sessionId;//get from server when login. saved in client 4
		int paddingint;//4
		bool guarantee; //1
		char paddingb[7];//7
		unsigned char data[900]; //904
		 
		
		SMsg()
			:msgId(-1),sessionId(-1),dataSize(0),time(0),guarantee(false),msgOrder(0)
		{}
	};


}